import java.util.ArrayList;
import java.util.LinkedList;

/*
 * @lc app=leetcode.cn id=78 lang=java
 *
 * [78] 子集
 */

// @lc code=start
class Solution {
    List<List<Integer>> res=new ArrayList<>();
    LinkedList<Integer> path=new LinkedList<>();
    public List<List<Integer>> subsets(int[] nums) {
        dfs(nums, 0);
        return res;   
    }
    public void dfs(int[] nums,int startIndex){
        res.add(new LinkedList<>(path));
        if(startIndex>=nums.length){
            return;
        }
        for(int i=startIndex;i<nums.length;i++){
            path.add(nums[i]);
            dfs(nums, i+1);
            path.removeLast();
        }
    }
}
// @lc code=end

